import axios from 'axios'

export default {
	/**
	 * 获取分类数据集合
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	fetch (params) {
		return axios.get('/api/category', {
			params: params
		});
	},
	/**
	 * 根据ID获取分类信息
	 * @param id
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	fetchByID (id, params) {
		return axios.get(`/api/category/${id}`, {
			params: params
		});
	},
	/**
	 * 创建分类信息
	 * @returns {AxiosPromise<any>}
	 */
	store (params) {
		return axios.post('/api/category', params);
	},
	/**
	 * 更新分类信息
	 * @param id
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	update (id, params) {
		return axios.patch(`/api/category/${id}`, params);
	},
	/**
	 * 删除分类信息
	 * @param id
	 * @returns {AxiosPromise}
	 */
	destroy (id) {
		return axios.delete(`/api/category/${id}`);
	},
	/**
	 * 根据分类ID 绑定任务
	 * @param id
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	attachTaskById (id, params) {
		return axios.post(`api/category/${id}/attachTasks`, params);
	}
}
